﻿

Dcqtech_Form_Controls.Attach = window.$.extend({}, Dcqtech_Form_Controls.Default);

Dcqtech_Form_Controls.Attach.setValue = function (id,value, wdInfo,$root) {
        var length = 0;
        if (value) {
            length = value.split(',').length;
        }
        $root.find("[dcqtech_data='" + id + "']").val(value);
        $root.find("[dcqtech_id='" + id + "'] input.form-control").val(length + "个附件。");
        $root.find("[dcqtech_id='" + id + "'] span.files-tips").val(length + "个附件");
        if(value){
            loadFiles(id, value)
        }
}

Dcqtech_Form_Controls.Attach.setDefaultValue = function (id, $root, wdInfo) {
    $root.find("[dcqtech_id='" + id + "'] input.form-control").val("0个附件。");
    let file_cell = $("[dcqtech_id=" + id +"]")
    file_cell.addClass("file-cell");
    file_cell.find(".form-control").hide()
    file_cell.parent().next(".control-label").addClass("file-cell-control")
    file_cell.find(".input-group-btn").hide()
    file_cell.append("<span class='files-tips'>0个附件</span><i class='iconfont oa-jiantou'></i>")

    let fileTarget = {id: id, filesList: [], showFilesManager: false}
    vm.filesTargets.push(fileTarget)
    // // loadFiles(index)

}

Dcqtech_Form_Controls.Attach.setEditEvent = function (id, wdInfo, $root) {
    $("[dcqtech_id='" + id + "']").on("click",function () {
        console.log("------")
        vm.filesTargets.forEach((item)=>{
            if(item.id == id){
                item.showFilesManager = true
            }
        })
    })
};

//附件管理按钮事件
function dcq_controlClick_attachView(btn) {




}